﻿@using FineAdmin.Model;
@{
    ViewBag.Title = "优惠线报";
    var PostCategoryList = ViewBag.PostCategoryList as List<PostCategoryModel>;
    PostCategoryList = PostCategoryList.Where(m => m.Pid == 1).ToList();

    var PostsList = ViewBag.PostsList as List<PostsModel>;
}
@section styles{
    <style>
        .typename {
            font-size: 12px;
            color: #ff7f21;
            margin-right: 32px;
            float:right;
        }
    </style>
}
<div class="content whisper-content" id="content">
    <div class="cont w1000">
        <div class="title">
            <span class="layui-breadcrumb" lay-separator="|">

                <a href="/Tip/Index#content" @(ViewBag.CId == null ? "class=active" : "")>全部</a>
                @foreach (var item in PostCategoryList)
                {
                    <a href="/Tip?CId=@(item.Id)#content" @(ViewBag.CId == item.Id ? "class=active" : "")>@item.Name</a>
                }
            </span>
        </div>
        <div class="cont">
            <div class="whisper-list">
                @foreach (var item in PostsList)
                {
                    <div class="item-box">
                        <a href="/Tip/TipDetail?id=@item.Id">
                            <div class="item">
                                <div class="whisper-title">
                                    <i class="layui-icon layui-icon-date"></i>
                                    <span class="hour">@item.CreateTime.ToString("HH:mm")</span>
                                    <span class="date">@item.CreateTime.ToString("yyyy/MM/dd")</span>

                                    <span class="typename"><i class="layui-icon layui-icon-tabs"></i>@item.PostTypeName</span>
                                </div>
                                <p class="text-cont">
                                    @item.Title
                                </p>
                                <div class="op-list">
                                    <p class="like"><i class="layui-icon layui-icon-praise"></i><span>@item.Likes</span></p>
                                    <p class="edit"><i class="layui-icon layui-icon-tread"></i><span>@item.Trample</span></p>

                                </div>
                            </div>
                        </a>
                    </div>
                }
            </div>
        </div>
        <div id="demo" style="text-align: center;"></div>
    </div>
</div>
@section scripts{
    <script>
        var count = @ViewBag.Total;
        var page=@ViewBag.Page;
    </script>
    <script type="text/javascript">
        layui.config({
            base: '../BlogStatic/js/util/'
        }).use(['element', 'laypage', 'jquery', 'menu'], function () {
            element = layui.element, laypage = layui.laypage, $ = layui.$, menu = layui.menu;
            laypage.render({
                elem: 'demo'
                , limit: 10
                , curr: page
                , count: count //数据总数，从服务端得到
                , jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数

                    //首次不执行
                    if (!first) {
                        //do something
                        window.location.href = "/Tip/Index?CId=@(ViewBag.CId)&p=@ViewBag.Page";
                    }
                }
            });

            menu.init();
        })
    </script>
}
